package Task;

import java.util.Scanner;
//前缀和
public class Task34 {

    // 注意类名必须为 Main, 不要有任何 package xxx 信息
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //读入数据
        int n = in.nextInt(), q = in.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) arr[i] = in.nextInt();
        //2.预处理一个前缀和数组
        long[] dp = new long[n + 1];//防止溢出（数据过大）
        for (int i = 1; i <= n; i++) dp[i] = dp[i - 1] + arr[i];
        //3.使用前缀和数组
        while (q > 0) {
            int l = in.nextInt(), r = in.nextInt();
            System.out.println(dp[r] - dp[l - 1]);
            q--;
        }
    }
}
